This is a script for manipulating with sections/masterpages.
Please refer to the documentation for more detail.
This script is a FULL working version, not a demo.
If you found a bug in the script, let me know. All bug fixes and
updates are free for the registered users.
If you use it, please register.
If you would like something to say, e-mail is: ffpecjak@uni-lj.si
*/
options results;centriraj="rt_reqpos = reqpos_centerscr";call addlib("rexxreqtools.library",0,-30);status "filename";imedok=result;status "pathname";imedok1=result;imedok1=imedok1||'.sc';NL='0a'x;call rtezrequest("This script will heavily modify your document!!!"||NL||"We recommend that you save your work first","Proceed|Save as|Exit",,centriraj);if rtresult=3 then exit;if rtresult=2 then saveas;if rtresult=0 then exit;call rtezrequest("In which commands are you interested?","Sections|Master Page",,centriraj);if rtresult=1 then poglavje=1;else poglavje=2;if poglavje=1 then;do;call rtezrequest("What do you want to do with sections?","Add|Delete|Move|Copy|Swap|Exit",,centriraj);if rtresult=1 then naredi=1;if rtresult=2 then naredi=4;if rtresult=3 then;do;naredi=2;kajnajdelam=1;end;if rtresult=4 then naredi=5;if rtresult=5 then naredi=3;if rtresult=0 then exit;add=3;if naredi=1 then;do;call dodajpoglavje;add=1;end;if naredi=4 then;do;call zbrisipoglavje;add=0;end;call naredispisek;if add=0 then;do;prisili=0;call odvzemi;end;if add=1 then call dodaj;if naredi=2|naredi=5 then;do;if naredi=5 then;do;call rtgetstring("new","Enter name of the new section","Section Script by Jernej Pecjak",,centriraj);kakoime='"'||newstring||'"';kajnajdelam=0;end;getsectionsetup NAME;imepoglavja='"'||result||'"';call rtezrequest("How would you like to"||NL||"select the section to move?","Click|Write",,centriraj);if rtresult=1 then call vizualno;if rtresult=0 then call tekstualno;gotosection imekam;newsection text name "temporary" polozi;call naredispisek;call dodaj;ime1=imeodkod;ime2="temporary";call premaknigfxtotal;gotosection imeodkod;editbody;if kajnajdelam=1 then;do;prisili=1;call zbrisipoglavje;call naredispisek;call odvzemi;gotosection "temporary";sectionsetup NEWNAME imeodkod;redraw;end;else;do;gotosection "temporary";sectionsetup NEWNAME kakoime;end;end;if naredi=3 then;do;getsectionsetup NAME;imepoglavja='"'||RESULT||'"';call rtezrequest("How would you like to select the sections to swap?","Click|Write",,centriraj);if rtresult=1 then;do;call vizualnopod1;imezac=imeodkod;call vizualnopod1;imekam=imeodkod;imeodkod=imezac;if imekam=imeodkod then;do;rtezrequest("Are you joking?"||NL||"That are the same sections","Exit",,centriraj);exit;end;end;if rtresult=0 then call tekstualnozam;gotosection spisek.1;newsection TEXT name "temporary" after;ime1=imeodkod;ime2="temporary";call premaknigfxtotal;gotosection imeodkod;call pobrisipoglavje;ime1=imekam;ime2=imeodkod;call premaknigfxtotal;gotosection imekam;call pobrisipoglavje;ime1="temporary";ime2=imekam;call premaknigfxtotal;gotosection "temporary";removesection "temporary" force;gotosection imeodkod;sectionsetup NEWNAME "temporary";gotosection imekam;sectionsetup NEWNAME imeodkod;gotosection "temporary";sectionsetup NEWNAME imekam;end;end;if poglavje=2 then;do;call rtezrequest("What do you want to do with masterpages?","Copy|Move|Swap",,centriraj);if result=1 then naredi=1;if result=2 then naredi=2;if result=0 then naredi=3;if naredi=1 then;do;kopiraj=1;call delozmasterji;end;if naredi=2 then;do;kopiraj=0;call delozmasterji;end;if naredi=3 then;do;getsectionsetup NAME;imepoglavja=result;call naredispisek;gotosection i;newsection text name "temporary" after;gotosection imepoglavja;editleftmaster;kam=levi;odkod=levi;imeodkod=imepoglavja;imekam="temporary";between=1;call kopirajmaster;odkod= desni;kam=levi;imeodkod=imepoglavja;imekam=imepoglavja;gotosection imepoglavja;call brisilevimaster;call kopirajmaster;call brisidesnimaster;odkod=levi;kam= desni;imeodkod="temporary";imekam=imepoglavja;call kopirajmaster;removesection "temporary" force;gotosection imepoglavja;end;end;EXIT;Damjana:;Graphictool;FirstObject;stevec=0;do until result=0;objectid=result;stevec=stevec+1;setobjectparams objectid LINKED samopot.stevec;selectobject objectid;x=x.stevec;y=y.stevec;visina=visina.stevec;sirina=sirina.stevec;stran=stran.stevec;setobjectcoords objectid stran x y visina sirina;redraw;NextObject objectid;end;redraw;return;Damjanafix:;FirstObject selected;stevec=0;do until result=0;objectid=result;stevec=stevec+1;objectid.stevec=objectid;NextObject objectid SELECTED;end;do haj=1 for stevec;selectobject objectid.haj;getobjectcoords 0;PARSE VAR Result stran x y visina sirina;x=x-0.3175;y=y-0.3175;setobjectcoords 0 stran x y visina sirina;end;redraw;return;Damjana1:;stevec=0;GraphicTool;FirstObject;niobjekta=result;do until result=0;stevec=stevec+1;objectid=result;getobjectparams objectid LINKED;samopot.stevec=result;getobjectcoords objectid;parse var Result stran x y visina sirina;stran.stevec=stran;x.stevec=x;y.stevec=y;visina.stevec=visina;sirina.stevec=sirina;NextObject objectid;end;FirstObject;niobjekta=result;do until result=0;objectid=result;SelectObject objectid MULTIPLE;NextObject objectid;end;redraw;return niobjekta;ustvaripoglavje:;o=i;i=1;gotosection spisek.i;i=o;newsection text name "temp" after;i=0;spisek.i='temp';i=o;gotosection imepoglavja;return 0;PopraviGfx:;call bodymaster;call desnimaster;call levimaster;return;DesniMaster:;gotosection spisek.i;editrightmaster;Damjana1();cut;gotosection spisek.j;editrightmaster;if niobjekta>0 then;do;paste;call Damjana;end;return;LeviMaster:;gotosection spisek.i;editleftmaster;Damjana1();cut;gotosection spisek.j;editleftmaster;if niobjekta>0 then;do;paste;call Damjana;end;return;Bodymaster:;gotosection spisek.i;Damjana1();cut;gotosection spisek.j;if niobjekta>0 then;do;paste;call damjana;end;return;odvzemi:;tu=i+1;if spisek.tu=imepoglavja then preskok=1;else preskok=0;if preskok=0 then;do;i=1;do until spisek.i=imepoglavja;i=i+1;end;call ustvaripoglavje;do until i=0;niobjekta=1;i=i-1;j=i+1;call popravigfx;end;removesection "temp" force;gotosection imepoglavja;editbody;end;return;dodaj:;stspiskov=i;i=1;getsectionsetup NAME;imepoglavja='"'||result||'"';if spisek.i=imepoglavja then abk=1;else abk=0;if abk=0 then;do;do until spisek.i=imepoglavja;niobjekta=1;i=i+1;j=i-1;call popravigfx;end;gotosection imepoglavja;editbody;end;return;zbrisipoglavje:;do;getsectionsetup NAME;imepoglavja='"'||result||'"';if prisili=1 then;removesection imepoglavja force;else;removesection imepoglavja;getsectionsetup NAME;imepoglavja='"'||result||'"';end;return;dodajpoglavje:;call rtgetstring("main","Enter name of the new section","Section Script by Jernej Pecjak",,centriraj);ime='"'||newstring||'"';call rtezrequest("Do you want to insert it AFTER or BEFORE the current section?","After|Before",,centriraj);if rtresult=1 then potem=1;if rtresult=0 then potem=0;if potem=1 then NewSection text name ime after;if potem=0 then NewSection text name ime before;return;testirajobstoj:;prav=0;do x=1 for i;if upper(spisek.x)=upper(test) then prav=1;end;if prav=0 then;do;call rtezrequest("The section " test " does not exist!!!","Try again","Exit",,centriraj);if rtresult=0 then exit;naredilsem=0;end;else naredilsem=1;return;vizualno:;call vizualnopod1;call vizualnopod2;return;vizualnopod1:;start=1;if i<6 then;kolikokrat=i;else kolikokrat=5;izberi=0;if i<6 then nenaredi=0;else nenaredi=1;nenaredi1=1;do until izberi=1;testiraj="";testiraj2="Back|";konec=start+kolikokrat;do xx=start for kolikokrat;yy=i-xx+1;testiraj=testiraj xx||'.'||spisek.yy||NL;if xx<konec-1 then;testiraj2=testiraj2||xx||'|';else testiraj2=testiraj2||xx||'|Forward|Exit';end;call rtezrequest("Which section would you like to move??"||NL||testiraj,testiraj2,,centriraj);izberi=1;if rtresult=0 then exit;if rtresult=kolikokrat+2 then;do;if nenaredi=1 then;do;start=start+5;if i>start+5 then;do;kolikokrat=5;nenaredi=1;nenaredi1=1;end;else;do;nenaredi=0;kolikokrat=i-start+1;end;end;izberi=0;end;if rtresult=1 then;do;if nenaredi1=1 then;do;start=start-5;if start>0 then;do;kolikokrat=5;nenaredi=1;nenaredi1=1;end;else;do;if start=-4 then start=1;if i<5 then kolikokrat=i;else kolikokrat=5;nenaredi1=0;end;end;izberi=0;end;y=i-(rtresult+start-3);end;if rtresult=0 then exit;imeodkod=spisek.y;imeodkod1=y;return;vizualnopod2:;start=1;if i<6 then;kolikokrat=i;else kolikokrat=5;izberi=0;if i<6 then nenaredi=0;else nenaredi=1;nenaredi1=1;do until izberi=1;testiraj="";testiraj2="Back|";konec=start+kolikokrat;do xx=start for kolikokrat;yy=i-xx+1;testiraj=testiraj||' '||xx||'.'||NL||spisek.yy||NL;testiraj2=testiraj2||xx||'|';end;testiraj=testiraj||' '||xx||'.';testiraj2=testiraj2||xx||'|Forward|Exit';call rtezrequest("Where would you like to move the section?"||NL||testiraj,testiraj2,,centriraj);izberi=1;if rtresult=0 then exit;if rtresult=kolikokrat+3 then;do;if nenaredi=1 then;do;start=start+5;if i>start+5 then;do;kolikokrat=5;nenaredi=1;nenaredi1=1;end;else;do;nenaredi=0;kolikokrat=i-start+1;end;end;izberi=0;end;if rtresult=1 then;do;if nenaredi1=1 then;do;start=start-5;if start>0 then;do;kolikokrat=5;nenaredi=1;nenaredi1=1;end;else;do;if start=-4 then start=1;if i<5 then kolikokrat=i;else kolikokrat=5;nenaredi1=0;end;end;izberi=0;end;y=i-(rtresult+start-3);end;if y=i then;nemogoce=1;else;nemogoce=0;y=y+1;polozi=after;if nemogoce=1 then;do;y=y-1;polozi=before;end;imekam=spisek.y;testiraj=y-1;if (spisek.y=imeodkod)|(spisek.testiraj=imeodkod) then;do;rtezrequest("The section is already there!!!","Exit",,centriraj);exit;end;return;tekstualno:;naredilsem=0;do while naredilsem=0;call rtgetstring("new","Enter name of the new section to move/copy/swap","Section Script by Jernej Pecjak",,centriraj);imeodkod='"'||newstring||'"';test=imeodkod;call testirajobstoj;end;naredilsem=0;do while naredilsem=0;requesttext '"Section MOVE/COPY/SWAP by Jernej Pecjak" "Before or After which section to move?" ""';imekamtemp='"'||result||'"';test=imeodkod;call testirajobstoj;end;if imeodkod=imekamtemp then;do;call rtezrequest("It is already there!","Exit",,centriraj);exit;end;ff=0;spisek.0="abcdefg";do until upper(imekamtemp)=upper(spisek.ff);ff=ff+1;end;call rtezrequest("Do you want the section you are moving to be"||NL||"AFTER or BEFORE the one you selected?","After|Before|ABORT",,centriraj);if result=0 then exit;if result=1 then;do;polozi=after;ff=ff-1;end;if result=2 then;do;polozi=before;ff=ff+1;end;if upper(spisek.ff)=upper(imeodkod) then;do;call rtezrequest("It is already there!","Exit",,centriraj);exit;end;imekam=imekamtemp;return;naredispisek:;getsectionlist ".";spisek=result;i=0;newspisek=1;do until newspisek=0;i=i+1;odrezi=lastpos('.',spisek);dolzina=length(spisek);if odrezi=0 then odrezi= dolzina;newspisek= dolzina-odrezi;if newspisek=0 then spisek.i='"'||right(spisek, dolzina)||'"';else spisek.i='"'||right(spisek,newspisek)||'"';spisek= delstr(spisek,odrezi);end;return;testnacin:;if nacin=1 then editbody;if nacin=2 then editrightmaster;if nacin=3 then editleftmaster;return;premaknigfxtotal:;nacin=1;call premaknigfx;nacin=2;call premaknigfx;nacin=3;call premaknigfx;return;premaknigfx:;gotosection ime1;call testnacin;texttool;selectall;extract;if result>"" then nare=1;else nare=0;selectall;if nare=1 then;do;cut;paste;end;else copy;redraw;gotosection ime2;call testnacin;if nare=1 then paste;gotosection ime1;call testnacin;Damjana1();copy;redraw;gotosection ime2;call testnacin;if niobjekta>0 then;do;paste;call damjana;end;return;tekstualnozam:;naredilsem=0;do while naredilsem=0;call rtgetstring(,"Enter name of the section to swap","Section Script by Jernej Pecjak",,centriraj);imeodkod='"'||newstring||'"';test=imeodkod;call testirajobstoj;end;naredilsem=0;do while naredilsem=0;call rtgetstring(,"Swap with which section","Section Script by Jernej Pecjak",,centriraj);imekam='"'||newstring||'"';test=imeodkod;call testirajobstoj;end;if imeodkod=imekam then;do;call rtezrequest("It is already there!","Exit",,centriraj);exit;end;return;pobrisipoglavje:;texttool;selectall;clear;graphictool;damjana1();clear;editleftmaster;texttool;selectall;clear;graphictool;damjana1();clear;editrightmaster;selectall;clear;graphictool;damjana1();clear;return;brisidesnimaster:;editrightmaster;texttool;selectall;clear;graphictool;damjana1();clear;editbody;return;brisilevimaster:;editleftmaster;texttool;selectall;clear;graphictool;damjana1();clear;editbody;return;kopirajmaster:;if between=1 then gotosection imeodkod;if odkod=levi then editleftmaster;else editrightmaster;texttool;selectall;extract;if result>"" then nare=1;else nare=0;selectall;if nare=1 then;do;cut;paste;if kopiraj=0 then cut;end;else copy;redraw;if between=1 then gotosection imekam;if kam=levi then editleftmaster;else editrightmaster;if nare=1 then paste;if between=1 then gotosection imeodkod;if odkod=levi then editleftmaster;else editrightmaster;graphictool;damjana1();if kopiraj=1 then copy;else cut;if between=1 then gotosection imekam;if kam=levi then editleftmaster;else editrightmaster;if niobjekta>0 then;do;paste;call damjanafix;end;editbody;return;delozmasterji:;call rtezrequest("Copy what?","L->R|R->L|Between",,centriraj);if rtresult=1 then;do;kaj=1;call rtezrequest("Delete right master?","Yes|No",,centriraj);if rtresult=1 then call brisidesnimaster;odkod=levi;kam= desni;between=0;call kopirajmaster;end;if rtresult=2 then;do;kaj=2;call rtezrequest("Delete left master?","Yes|No",,centriraj);if rtresult=1 then call brisilevimaster;odkod= desni;kam=levi;between=0;call kopirajmaster;end;if rtresult=0 then;do;call naredispisek;getsectionsetup NAME;imepoglavja='"'||result||'"';call rtezrequest("How would you like to select the masters to copy","Click|Text",,centriraj);if rtresult=1 then;do;kaj=3;call vizualnopod1;imezac=imeodkod;call vizualnopod1;imekam=imeodkod;imeodkod=imezac;end;else call tekstualnozam;call rtezrequest("Which masterpage do you want to copy?","Left|Right|Both",,centriraj);if result=1 then mpage=1;if result=2 then mpage=2;if result=3 then mpage=3;if mpage=1 then;do;kam=levi;odkod=levi;call zbrisidestination;end;if mpage=2 then;do;kam= desni;odkod= desni;call zbrisidestination;end;if mpage=3 then;do;kam=levi;odkod=levi;between=1;call zbrisidestination;call kopirajmaster;kam= desni;odkod= desni;gotosection imekam;call brisidesnimaster;end;between=1;call kopirajmaster;end;return;zbrisidestination:;call rtezrequest("Delete destination before copy/move?","Yes|No",,centriraj);if rtresult=1 then;do;gotosection imekam;if kam=levi then call brisilevimaster;else call brisidesnimaster;end;return